package com.open.party.cloud.view

import androidx.fragment.app.Fragment
import cn.sinothk.hussars.views.scrollViewGridView.IconTextBean
import cn.android.x.model.SuperItemBean
import com.open.party.cloud.R
import com.open.party.cloud.model.data.LocalCache
import com.open.party.cloud.view.home.article.ArticleMainActivity
import com.open.party.cloud.view.home.eJia.EJiaMainActivity
import com.open.party.cloud.view.home.dangWuMiShu.DwmsDiaoChaWenJuanListActivity
import com.open.party.cloud.view.home.dangWuMiShu.DwmsTouPiaoGuanLiListActivity
import com.open.party.cloud.view.home.dangWuMiShu.DwmsYiJIanJianYiActivity
import com.open.party.cloud.view.home.dangYuanJiaoYu.YunKeTangListActivity
import com.open.party.cloud.view.examine.ExamineMainActivity
import com.open.party.cloud.view.home.gongwuyuanguanli.BizGuideListMainActivity
import com.open.party.cloud.view.home.jiCengDangJian.DyfzMainActivity
import com.open.party.cloud.view.home.jiCengDangJian.JcdjCommunityMapActivity
import com.open.party.cloud.view.home.jiCengDangJian.partyService.ZyzServiceMainActivity
import com.open.party.cloud.view.home.juBao.JuBao12380ChaXunSearchActivity
import com.open.party.cloud.view.home.juBao.JuBao12380RuXuZhiActivity
import com.open.party.cloud.view.home.renCaiGongZuo.ZhuanJiaMainActivity
import com.open.party.cloud.view.home.ziShenJiaoYu.ZiShenJianSheLeaderListInfoActivity
import com.open.party.cloud.view.login.LoginActivity
import com.sinothk.android.utils.XUtils
import com.sinothk.android.utils.inters.OnSuperListener

open class HomeMainBaseFragment1011 : Fragment(), OnSuperListener<IconTextBean> {

    protected fun getIconTxt(): ArrayList<IconTextBean> {
        val listData = ArrayList<IconTextBean>()
        listData.add(IconTextBean(R.drawable.zgdt_szyw, "时政要闻"))
        listData.add(IconTextBean(R.drawable.zgdt_zgdt, "组工动态"))
        listData.add(IconTextBean(R.drawable.zgdt_tszs, "他山之石"))
        listData.add(IconTextBean(R.drawable.zgdt_xjdx, "凉都先锋"))
        listData.add(IconTextBean(R.drawable.zgdt_tzgg, "通知公告"))

        listData.add(IconTextBean(R.drawable.zsjs_xncx, "自身建设"))
        listData.add(IconTextBean(R.drawable.zsjs_ldxx, "领导之窗"))
        return listData
    }

    protected fun getIconTxt2(): ArrayList<IconTextBean> {
        val listData = ArrayList<IconTextBean>()
        listData.add(IconTextBean(R.drawable.tsgz_zcfg, "政策法规"))
        listData.add(IconTextBean(R.drawable.tsgz_rqgs, "任免公示"))
        listData.add(IconTextBean(R.drawable.tsgz_gzlc, "干部管理"))
//        listData.add(IconTextBean(R.drawable.tsgz_jyjl, "经验交流"))
        
//        listData.add(IconTextBean(R.drawable.dwms_tpgl, "干部考试"))

//        listData.add(IconTextBean(R.drawable.gwygl_zcfg, "政策法规_1"))
        listData.add(IconTextBean(R.drawable.gwygl_ywzn, "公务员管理"))
        return listData
    }

    protected fun getIconTxt3(): ArrayList<IconTextBean> {
        val listData = ArrayList<IconTextBean>()
        listData.add(IconTextBean(R.drawable.dygb_pxydt, "培训云动态"))
        listData.add(IconTextBean(R.drawable.dygb_ldykt, "凉都云课堂"))
        listData.add(IconTextBean(R.drawable.dygb_pxkspt, "培训考试云平台"))
        return listData
    }

    protected fun getIconTxt4(): ArrayList<IconTextBean> {
        val listData = ArrayList<IconTextBean>()
        listData.add(IconTextBean(R.drawable.jcdj_sqdh, "基层组织概况"))
//        listData.add(IconTextBean(R.drawable.jcdj_dyfw, "党员服务"))
        listData.add(IconTextBean(R.drawable.jcdj_dyfz, "党员发展"))
//        listData.add(IconTextBean(R.drawable.jcdj_dzzhj, "党组织换届"))
//        listData.add(IconTextBean(R.drawable.jcdj_djdt, "党建动态"))
        listData.add(IconTextBean(R.drawable.jcdj_djej, "党建E家"))

        listData.add(IconTextBean(R.drawable.jcdj_dyfw, "农村党建"))
        listData.add(IconTextBean(R.drawable.gwygl_zcfg, "城市党建"))
        listData.add(IconTextBean(R.drawable.rcgz_zcgg, "两新党建"))
        return listData
    }

    protected fun getIconTxt5(): ArrayList<IconTextBean> {
        val listData = ArrayList<IconTextBean>()
//        listData.add(IconTextBean(R.drawable.rcgz_zcgg, "政策公告"))
        listData.add(IconTextBean(R.drawable.rcgz_rcyj, "人才服务"))
        listData.add(IconTextBean(R.drawable.rcgz_zjfc, "专家服务"))
        return listData
    }

//    protected fun getIconTxt6(): ArrayList<IconTextBean> {
//        val listData = ArrayList<IconTextBean>()
//        listData.add(IconTextBean(R.drawable.gwygl_zcfg, "政策法规_1"))
//        listData.add(IconTextBean(R.drawable.gwygl_ywzn, "公务员管理"))
//        return listData
//    }

    protected fun getIconTxt7(): ArrayList<IconTextBean> {
        val listData = ArrayList<IconTextBean>()
        listData.add(IconTextBean(R.drawable.jbpt_rxz, "举报须知"))
        listData.add(IconTextBean(R.drawable.jbpt_fkcx, "反馈查询"))
        return listData
    }

//    protected fun getIconTxt8(): ArrayList<IconTextBean> {
//        val listData = ArrayList<IconTextBean>()
//        listData.add(IconTextBean(R.drawable.zsjs_ldxx, "领导之窗"))
////        listData.add(IconTextBean(R.drawable.zsjs_jgsz, "机构设置"))
////        listData.add(IconTextBean(R.drawable.jcdj_dyfw, "党群建设"))
//        listData.add(IconTextBean(R.drawable.zsjs_xncx, "自身建设"))
//        listData.add(IconTextBean(R.drawable.zsjs_bjgdj, "机关党建"))
//
////        listData.add(IconTextBean(R.drawable.zsjs_xxhjs, "基层组织概况"))
//        return listData
//    }

    protected fun getIconTxt9(): ArrayList<IconTextBean> {
        val listData = ArrayList<IconTextBean>()
        listData.add(IconTextBean(R.drawable.dwms_tpgl, "投票管理"))
        listData.add(IconTextBean(R.drawable.dwms_dcwj, "调查问卷"))
        listData.add(IconTextBean(R.drawable.dwms_yjjy, "意见建议"))
        return listData
    }

//    private fun gotoZiShenJianShe(index: Int) {
//        //自身建设
//        val itemList = ArrayList<SuperItemBean>()
////        itemList.add(SuperItemBean("ZSJS_DQJS", "党群建设"))
//        itemList.add(SuperItemBean("ZSJS_XNCX", "自身建设"))
//        itemList.add(SuperItemBean("ZSJS_BJGDJ", "机关党建"))
////        itemList.add(SuperItemBean("ZSJS_XXHJS", "基层组织概况"))
//
//        XUtils.intent().openActivity(activity, ArticleMainActivity::class.java)
//            .putStringExtra("title", "综合管理")
//            .putIntExtra("index", index)
//            .putSerializableExtra("itemList", itemList)
//            .startInFragment(this)
//    }

//    private fun gotoGongWuYuanGuanLi(index: Int) {
//        // 公务员管理
//        val itemList = ArrayList<SuperItemBean>()
//        itemList.add(SuperItemBean("GWYGL_ZCFG", "政策法规"))
////        itemList.add(SuperItemBean("GWYGL_YWZN", "公务员管理"))
//
//        XUtils.intent().openActivity(activity, ArticleMainActivity::class.java)
//            .putStringExtra("title", "公务员管理")
//            .putIntExtra("index", index)
//            .putSerializableExtra("itemList", itemList)
//            .startInFragment(this)
//    }

    private fun gotoRenCaiGongGao(index: Int) {
        // 人才公告
        val itemList = ArrayList<SuperItemBean>()
//        itemList.add(SuperItemBean("RCGZ_ZCGG", "政策公告"))
        itemList.add(SuperItemBean("RCGZ_RCYJ", "人才服务"))
//        itemList.add(SuperItemBean("RCGZ_ZJFC", "专家服务"))

        XUtils.intent().openActivity(activity, ArticleMainActivity::class.java)
            .putStringExtra("title", "人才服务")
            .putIntExtra("index", index)
            .putSerializableExtra("itemList", itemList)
            .startInFragment(this)
    }

    private fun gotoJiChuDangJian(index: Int) {
        // 基础党建
        val itemList = ArrayList<SuperItemBean>()
//        itemList.add(SuperItemBean("JCDJ_DZZHJ", "党组织换届"))
//        itemList.add(SuperItemBean("JCDJ_DJDT", "党建动态"))
        itemList.add(SuperItemBean("JCDJ_NCDJ", "农村党建"))
        itemList.add(SuperItemBean("JCDj_CSDJ", "城市党建"))
        itemList.add(SuperItemBean("JCDj_LXDJ", "两新党建"))

        XUtils.intent().openActivity(activity, ArticleMainActivity::class.java)
            .putStringExtra("title", "基层党建")
            .putIntExtra("index", index)
            .putSerializableExtra("itemList", itemList)
            .startInFragment(this)
    }

    private fun gotoDangGanBuJiaoYu() {
        // 党员干部教育
        val itemList = ArrayList<SuperItemBean>()
        itemList.add(SuperItemBean("DYGBJY_PXYDT", "培训云动态"))

        XUtils.intent().openActivity(activity, ArticleMainActivity::class.java)
            .putStringExtra("title", "党员干部教育")
            .putIntExtra("index", 0)
            .putSerializableExtra("itemList", itemList)
            .startInFragment(this)
    }

    private fun gotoGanBuGongZuo(index: Int) {
        // 干部工作
        val itemList = ArrayList<SuperItemBean>()
        itemList.add(SuperItemBean("GBGZ_ZCFG", "政策法规"))
        itemList.add(SuperItemBean("GBGZ_RQGS", "任免公示"))
        itemList.add(SuperItemBean("GBGZ_GZLC", "干部管理"))

        XUtils.intent().openActivity(activity, ArticleMainActivity::class.java)
            .putStringExtra("title", "干部工作")
            .putIntExtra("index", index)
            .putSerializableExtra("itemList", itemList)
            .startInFragment(this)
    }

    private fun gotoZuGongDongTai(index: Int) {
        // 组工动态
        val itemList = ArrayList<SuperItemBean>()
        itemList.add(SuperItemBean("HOME_SZYW", "时政要闻"))
        itemList.add(SuperItemBean("HOME_ZGDT", "组工动态"))
        itemList.add(SuperItemBean("HOME_TSZS", "他山之石"))
        itemList.add(SuperItemBean("HOME_XJDX", "凉都先锋"))
        itemList.add(SuperItemBean("HOME_TZGG", "通知公告"))
        itemList.add(SuperItemBean("ZSJS_XNCX", "自身建设"))

        XUtils.intent().openActivity(activity, ArticleMainActivity::class.java)
            .putStringExtra("title", "组工动态")
            .putIntExtra("index", index)
            .putSerializableExtra("itemList", itemList)
            .startInFragment(this)
    }

    override fun onClick(position: Int, itemData: IconTextBean, flag: String) {
        when (itemData.text) {
            // 组工动态============================================
            "时政要闻" -> {
                gotoZuGongDongTai(0)
                return
            }
            "组工动态" -> {
                gotoZuGongDongTai(1)
                return
            }
            "他山之石" -> {
                gotoZuGongDongTai(2)
                return
            }
            "凉都先锋" -> {
                gotoZuGongDongTai(3)
                return
            }
            "通知公告" -> {
                gotoZuGongDongTai(4)
                return
            }
            "自身建设" -> {
                gotoZuGongDongTai(5)
                return
            }
            // 干部工作============================================
            "政策法规" -> {
                gotoGanBuGongZuo(0)
                return
            }
            "干部管理" -> {
                gotoGanBuGongZuo(2)
                return
            }
            "任免公示" -> {
                gotoGanBuGongZuo(1)
                return
            }

            // 党员干部教育==============================================
            "培训云动态" -> {
                gotoDangGanBuJiaoYu()
                return

            }
            // 基础党建 ==============================================
//            "党员服务" -> {
//                XUtils.intent().openActivity(activity, ZyzServiceMainActivity::class.java).startInFragment(this)
//                return
//            }
            "党员发展" -> {
                XUtils.intent().openActivity(activity, DyfzMainActivity::class.java).startInFragment(this)
                return
            }
//            "党组织换届" -> {
//                gotoJiChuDangJian(0)
//                return
//            }
//            "党建动态" -> {
//                gotoJiChuDangJian(0)
//                return
//            }
            "农村党建" -> {
                gotoJiChuDangJian(0)
                return
            }
            "城市党建" -> {
                gotoJiChuDangJian(1)
                return
            }
            "两新党建" -> {
                gotoJiChuDangJian(2)
                return
            }

            // 人才工作==============================================
//            "政策公告" -> {
//                gotoRenCaiGongGao(0)
//                return
//            }
            "人才服务" -> {
                gotoRenCaiGongGao(0)
                return
            }
            "专家服务" -> {
                XUtils.intent().openActivity(activity, ZhuanJiaMainActivity::class.java).startInFragment(this)
                return
            }

            // 公务员管理==============================================
//            "政策法规_1" -> {
//                gotoGongWuYuanGuanLi(0)
//                return
//            }
            "公务员管理" -> {
//                gotoGongWuYuanGuanLi(1)
                XUtils.intent().openActivity(activity, BizGuideListMainActivity::class.java).startInFragment(this)
                return
            }
            // 自身建设==============================================
//            "党群建设" -> {
//                gotoZiShenJianShe(0)
//                return
//            }
//            "机关党建" -> {
//                gotoZiShenJianShe(1)
//                return
//            }
//            "基层组织概况" -> {
//                gotoZiShenJianShe(2)
//                return
//            }
            "领导之窗" -> {
                XUtils.intent().openActivity(activity, ZiShenJianSheLeaderListInfoActivity::class.java)
                    .startInFragment(this)
                return
            }

            //  党务秘书
            "意见建议" -> {
                XUtils.intent().openActivity(activity, DwmsYiJIanJianYiActivity::class.java)
                    .startInFragment(this)
            }
        }

        // 需要登录项
        if (!LocalCache.getAutoLogin()) {
            // 登录检测
            XUtils.intent().openActivity(activity, LoginActivity::class.java)
                .startInFragment(this)
        }

        when (itemData.text) {
//            "干部考试"->{
//                XUtils.intent().openActivity(activity, ExamineMainActivity::class.java)
//                    .putStringExtra("titleName", "我的考试")
//                    .startInFragment(this)
//            }



            "基层组织概况" -> {
                XUtils.intent().openActivity(activity, JcdjCommunityMapActivity::class.java).startInFragment(this)
                return
            }

            "凉都云课堂" -> {
                XUtils.intent().openActivity(activity, YunKeTangListActivity::class.java).startInFragment(this)
                return
            }

            "培训考试云平台" -> {
                XUtils.intent().openActivity(activity, ExamineMainActivity::class.java)
                    .putStringExtra("titleName", "培训考试云平台")
                    .startInFragment(this)
            }

            //  1280举报平台
            "反馈查询" -> {
                XUtils.intent().openActivity(activity, JuBao12380ChaXunSearchActivity::class.java)
                    .startInFragment(this)
            }

            "举报须知" -> {
                XUtils.intent().openActivity(activity, JuBao12380RuXuZhiActivity::class.java)
                    .startInFragment(this)
            }

            "调查问卷" -> {
                XUtils.intent().openActivity(activity, DwmsDiaoChaWenJuanListActivity::class.java)
                    .startInFragment(this)
            }

            "投票管理" -> {
                XUtils.intent().openActivity(activity, DwmsTouPiaoGuanLiListActivity::class.java)
                    .startInFragment(this)
            }


        }
    }
}